Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@targomo/core

Package Overview
Dependencies
Maintainers
3
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@targomo/core

The JavaScript (& TypeScript) API for Targomo's time-based access mapping services.

  • 0.5.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2K
decreased by-40.96%
Maintainers
3
Weekly downloads
 
Created
Source

The Targomo-js and Targomo-js-extensions libraries are the best choice for using our services on a web page using Typescript or JavaScript. Both of these libraries are available as an NPM package, or you can get them via our CDN.

Targomo-js is a library which allows you to make use of our services with Typescript or Javascript, without having to deal with HTTP requests yourself. This simplifies and speeds up your development process, without compromising the flexibility or capabilities of the REST API.

This library can be used on its own just fine. However, there is a good chance that you'll want to visualize the results we provide on a map of some sorts. To help you with this, we developed a secondary library: Targomo-js-extensions. As the name suggests, this is an optional libary which contains some extensions for Targomo-js. These extensions are focused on visualizations of the returned results from Targomo-js, on Google Maps or Leaflet.

Installing

You can install Targomo-js using NPM, or you can use our CDN to get the latest version of our library.

  • Targomo-js: npm install @targomo/core
  • Targomo-js-extensions for Leaflet: npm install @targomo/leaflet
  • Targomo-js-extensions for Google Maps: npm install @targomo/googlemaps

Or you can access our CDN with the following urls.

  • Targomo-js: https://releases.targomo.com/core/latest.js
  • Targomo-js-extensions for Leaflet: https://releases.targomo.com/leaflet/latest.js
  • Targomo-js-extensions for Google Maps: https://releases.targomo.com/googlemaps/latest.js

Once installed, initialize the Targomo client.

When using the CDN in a script tag, 'tgm' is automatically added to the global scope. In this case initialize the client like so:

const client = new tgm.TargomoClient('westcentraleurope', 'your API key');

Otherwise, when using npm in combination with TS/ES6:

import { TargomoClient } from '@targomo/core' 
const client = new TargomoClient('westcentraleurope', 'your API key');

Use the client. For example for requesting geojson travel time polygons:

const sources = [{ 
    lng: 13.3786431, 
    lat: 52.4668237, 
    id: 1
}, {
    lng: 52.388166,
    lat: 13.120117,
    id: 2
}]

const polygons = await tgmClient.polygons.fetch(sources, {
  travelType: 'walk',                   // Either 'walk', 'bike', 'car' or 'transit'
  travelEdgeWeights: [300, 600, 900],   // Array of distinct travel times in seconds
  serializer: 'geojson'               
})

Get your own Targomo API key here, and check out our availability map, to see which regions you can choose from.

If you installed either the Leaflet or Google Maps extensions, then they will be available under the following context in your JavaScript/TypeScript app. tgm.leaflet or tgm.googlemaps.

Take a look at our JavaScript code examples for a more detailed look on how to use our libraries.

Keywords

FAQs

Package last updated on 02 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc